package com.example.springsecurity.security;

import com.example.springsecurity.entity.UserInfo;
import lombok.NoArgsConstructor;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Component;

/**
 * @Author: xieyonghui
 * @Date: 2019/7/10
 * @Description:
 */
@Component("myUserDetailsServiceImpl")
public class MyUserDetailsServiceImpl implements UserDetailsService {

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        if(username.equals("admin"))
        {
            //暂时模拟返回用户信息如下; (可以从数据库中获取)
            UserInfo userInfo=new UserInfo("admin", "123456", "ROLE_ADMIN", true,true,true, true);
            return userInfo;
        }
        return null;
    }
}   
